<template>
  <div class="myContainer">        
     <el-row class="myTitleBorderBottom">
      <el-col :span="20" class="myLineHeight_40px">
        记录信息
      </el-col>
    </el-row>
    <el-form :model="detail" :rules="rules" ref="ruleForm">    	
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         记录ID:
      </el-col>
      <el-col :span="7">        
            <el-input :readonly="is_modifly" v-model="id" placeholder="请输入记录ID"></el-input>          
      </el-col>
    </el-row>  
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      	
           创建时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="create_time"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>  
      </el-col>
    </el-row>
   <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         租户ID:
      </el-col>
      <el-col :span="7">        
            <el-input :readonly="is_modifly" v-model="tenant_id" placeholder="请输入租户ID"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         子账号ID:
      </el-col>
      <el-col :span="7">        
            <el-input :readonly="is_modifly" v-model="account_id" placeholder="请输入子账号ID"></el-input>          
      </el-col>
    </el-row>       
    <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          用户信息
        </el-col>
     </el-row>    
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
        用户ID:
      </el-col>
     <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="user_id" placeholder="请输入用户ID"></el-input>          
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         用户姓名:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="user_name" placeholder="请输入用户姓名"></el-input>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         用户电话:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="user_phone" placeholder="请输入用户电话"></el-input>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
        用户工号:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="employee_number" placeholder="请输入用户工号"></el-input>          
      </el-col>
    </el-row>
      <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         用户所在组织ID:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="organization_id" placeholder="请输入用户所在组织ID"></el-input>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         用户所在组织名称:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="organization_name" placeholder="请输入用户所在组织名称"></el-input>          
      </el-col>
    </el-row>
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         用户注册时照片:
      </el-col>
      <el-col :span="7">       
          <el-col :span="6">
          <img class="myImg" src="static/images/timg.jpg" v-if="imageUrl=='' || imageUrl==null" alt="">
          <img class="myImg" :src="imageUrl" v-else alt="">
        </el-col>          
      </el-col>
    </el-row>
    <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          识别信息
        </el-col>
      </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
      	
           识别时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="sysc_time"
          :disabled="is_modifly"
          type="datetime"
          format="yyyy-MM-dd-HH-mm-ss"
          value-format="yyyy-MM-dd-HH-mm-ss"
          placeholder="请选择识别时间">
        </el-date-picker>  
      </el-col>
    </el-row>
           <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         区域ID:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="area_id" placeholder="请输入区域ID"></el-input>          
      </el-col>
    </el-row>
           <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         区域名称:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="area_name" placeholder="请输入区域名称"></el-input>          
      </el-col>
    </el-row>
           <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">     	
        通行方式：
      </el-col>
      <el-col :span="7">      	
        <template>
          <el-select 
            v-model="identify"
            :disabled="is_modifly"
            clearable
            placeholder="识别结果">
            <el-option
              v-for="item in identifyList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
           <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         IC卡号:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="ic_number" placeholder="请输入IC卡号"></el-input>          
      </el-col>
    </el-row>
           <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         识别抓拍照片:
      </el-col>
      <el-col :span="7">       
            <el-col :span="6">        
          <img class="myImg_1" :src="imageUrl_1"  alt="">
        </el-col>          
      </el-col>
    </el-row>
           <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         近距离红外照片:
      </el-col>
      <el-col :span="7">       
             <el-col :span="6">
          <img class="myImg_1" :src="imageUrl_2"  alt="">
        </el-col>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">     	
       进出方式：
      </el-col>
      <el-col :span="7">      	
        <template>
          <el-select 
            v-model="type"
            :disabled="is_modifly"
            clearable
            placeholder="进出方式">
            <el-option
              v-for="item in typeList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
        <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">     	
       识别结果：
      </el-col>
      <el-col :span="7">      	
        <template>
          <el-select 
            v-model="result_type"
            :disabled="is_modifly"
            clearable
            placeholder="识别结果">
            <el-option
              v-for="item in discernList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
        <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         识别错误原因:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="reject_reason" placeholder="请输入识别错误原因"></el-input>          
      </el-col>
    </el-row>       
       <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">     	
       是否作为考勤使用：
      </el-col>
      <el-col :span="7">      	
        <template>
          <el-select 
            v-model="attendance_flag"
            :disabled="is_modifly"
            clearable
            placeholder="是否作为考勤使用">
            <el-option
              v-for="item in whetherkqList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
     <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          设备信息
        </el-col>
      </el-row>
        <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         设备ID:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_id"  placeholder="请输入设备ID"></el-input>          
      </el-col>
    </el-row>
      <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         设备SN号:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_sn"  placeholder="请输入设备SN号"></el-input>          
      </el-col>
    </el-row>
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         设备名称:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_name" placeholder="请输入设备名称"></el-input>          
      </el-col>
    </el-row>
        <el-row class="myMarginTop_10px">
     <el-col :span="3" class="myLeftMsg">     	
       设备类型：
      </el-col>
      <el-col :span="7">      	
        <template>
          <el-select 
            v-model="device_type"
            :disabled="is_modifly"
            clearable
            placeholder="请选择设备类型">
            <el-option
              v-for="item in deviceTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>        
      </el-col>
    </el-row> 
      <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">        
         设备类型名称:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="device_type_name"  placeholder="请输入设备类型名称"></el-input>          
      </el-col>
    </el-row>  
    <el-row class="myMarginTop_10px">
      <el-col :span="7" :offset="3">
        <el-button type="primary" class="myBgGreen" @click="onBack">返 回</el-button>
      </el-col>
    </el-row>
  </el-form>      
  </div>
</template>

<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myLeftMsg{
    line-height: 40px;
    text-align: right;
    padding-right: 10px;
  }
  .myMarginTop_10px{
    padding-bottom: 10px;
  }
  .myImg{
    width: 160px;
    /*height: 160px;*/
    /*border-radius: 50% !important;*/
  }
  .myImg_1{
  	width: 160px;
  	/*height: 180px;*/
  }
  .myVA_M{
    vertical-align: middle;
  }
  .myMarginBottom_10px{
    margin-bottom: 20px;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border:1px solid #d8dce5;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
<script>

  import { getJumpValue , addAd , getAd , editAd } from '@/api/online';
   import { getManThroughDetail } from '@/api/entrance_guard';
  import { r_email , r_phone } from "@/api/regular";//正则
  export default {
    data(){
      return{
        title: "人员通行管理",
        id: "",
        is_modifly:false,
        type:"",
        ad_name:"",
         detail:{
          
        },                   
        ad_jumpValue:"",
        imageUrl:"",
        imageUrl_1:"",
        imageUrl_2:'',
        ADDESC:"",
        device_type_name:"",
        device_name:"",
        device_sn:"",
        device_id:"",
        reject_reason:"",
        ic_number:"",
        area_name:"",
        area_id:"",
        sysc_time:"",
        organization_name:"",
        organization_id:"",
        employee_number:"",
        user_phone:"",
        user_name:"",
        user_id:"",
        account_id:"",
        create_time:"",
        id:"",
        tenant_id:"",
        identify:"",
        identifyList:[{value:'0',label:"人脸识别"},{value:'1',label:"IC卡识别"}],
        type:"",
        typeList:[{value:"0",label:"进"},{value:"1",label:"出"}],
        result_type:"",
        discernList:[{value:"0",label:"成功"},{value:"1",label:"失败"}],        
        attendance_flag:"",
        whetherkqList:[{value:0,label:"是"},{value:1,label:"否"}],
        device_type:"",
        deviceTypeList:[{value:'1001',label:"单屏"},{value:'2001',label:"闸机"},{value:'3001',label:"桌面双屏"},{value:'4001',label:"门禁"},{value:'5001',label:"摄像头"}],
        rules: {
         
          card_no:[
            {required: true, message: '不能为空！', trigger: 'blur'},
            
            ],          
          },
      }
    },
    components: {
        
    },
    created(){
      document.title=this.title;
      this.type = this.$route.query.type;
      this.id = this.$route.query.id;
      if(this.type=='add'){

      }
      if(this.type=='info'){
        this.onGetAd();
        this.is_modifly = true;
        this.is_disabled = true;
      }
      
    },
    methods:{     
      onEditAd(){
        let vm=this;
        let params={          
          ADDESC:vm.ADDESC,
          
        }
        editAd(params).then(response => {
          console.log("修改成功")
          this.$message.success('执行成功！');
          this.$router.go(-1);
        }).catch(error => {
          this.$message.error('执行失败！');
          console.log("修改失败")
        })
      },
      onCreate(){//添加
        let vm=this;
        let params={
        
          ADDESC:vm.ADDESC,
        }
        addAd(params).then(response => {
          let res=response.data;
          vm.$message.success("添加数据成功！");
          this.$router.go(-1);
          console.log("添加成功",res);
        }).catch(error => {
          vm.$message.error("添加数据失败！");
          console.log("添加失败",error);
        })
        console.log(params)
      },
      onBack(){//返回
      	let vm =this;
      	window.localStorage.setItem('pageNum',vm.$route.query.pageNum||1);
        this.$router.go(-1);
      },
      
      onGetAd(){//拉取
        let vm=this;
       
        getManThroughDetail(vm.id).then(response => {
          let res=response.data;
          vm.device_type_name=res.device_type_name;
          vm.device_name=res.device_name;
          vm.device_sn=res.device_sn;
          vm.device_id=res.device_id;
          vm.reject_reason=res.reject_reason;
          vm.ic_number=res.ic_number;
          vm.area_name=res.area_name;
          vm.area_id=res.area_id;
          vm.sysc_time=res.sysc_time;
          vm.organization_name=res.organization_name;
          vm.organization_id=res.organization_id;
          vm.employee_number=res.employee_number;
          vm.user_phone=res.user_phone;
          vm.user_name=res.user_name;
          vm.imageUrl=res.image_uri;
          vm.user_id=res.user_id;
          vm.account_id=res.account_id;
          vm.create_time=res.create_time;
          vm.id=res.id;
          vm.type=res.type;
          vm.identify=res.identify;
          vm.result_type=res.result_type;
          vm.attendance_flag=res.attendance_flag;
          vm.device_type=res.device_type;
          vm.tenant_id=res.tenant_id;
          vm.imageUrl_1=res.visible_light_pic;
          vm.imageUrl_2=res.near_infrared_pic;
        }).catch(error => {
          console.log("拉取数据失败",error);
        })
      } 
      

    }
  
  }


</script>


